package com.itchen.controller;

import com.itchen.exception.BusinessException;
import com.itchen.exception.SystemException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author げっしょく
 * @date 2021/9/16
 */

@RestControllerAdvice
public class ProjectExceptionAdvice {

    @ExceptionHandler
    public Result hadlerSystemException(SystemException ex) {
        System.out.println("SystemException");
        return new Result(ex.getflag(), ex.getMessage());
    }


    @ExceptionHandler
    public Result handlerBusinessException(BusinessException ex) {
        System.out.println("BusinessException");
        return new Result(ex.getflag(), ex.getMessage());
    }


    @ExceptionHandler
    public Result handlerException(Exception ex) {
        System.out.println("Exception");
        return new Result(false, "系统繁忙，请稍后再试");
    }
}
